package org.op.service.ui;

import javax.swing.JFrame;
import javax.swing.UIManager;

import org.op.service.config.ConfigKeys;
import org.op.service.config.ConfigurationService;

public class UiServiceImpl implements UiService {

	private ConfigurationService configService;
	
	public void configureUI() {
		
		// This is a JGoodies option
        //UIManager.put(Options.USE_SYSTEM_FONTS_APP_KEY, Boolean.TRUE);
        //Options.setDefaultIconSize(new Dimension(18, 18));

        String lafName = configService.getProperty(ConfigKeys.KEY_LOOK_AND_FEEL);
        if (lafName==null && lafName.trim().equals("")) {
        	// default LAF if not specified
        	
        	// 	This is a JGoodies option
        	//lafName = LookUtils.IS_OS_WINDOWS_XP
            //        ? Options.getCrossPlatformLookAndFeelClassName()
            //        : Options.getSystemLookAndFeelClassName();
        	
        	lafName = "";
        }

        try {
            UIManager.setLookAndFeel(lafName);
        	decorateFrame(Boolean.TRUE);
        } catch (Exception e) {
            System.err.println("Can't set look & feel:" + e);
        }

	}
	
	public void decorateFrame(Boolean decorate) throws Exception {
		// TODO - not working with swingwt
		JFrame.setDefaultLookAndFeelDecorated(true);
	}

	public ConfigurationService getConfigService() {
		return configService;
	}

	public void setConfigService(ConfigurationService configService) {
		this.configService = configService;
	}
	
	

}
